package com.work.straighttalk.model;

import android.text.TextUtils;
import android.widget.Toast;

import com.work.straighttalk.bean.User;
import com.work.straighttalk.model.i.OnSearchUserListener;
import com.work.straighttalk.model.i.SearchUserMI;

import java.util.List;

import cn.bmob.v3.listener.FindListener;

/**
 * Created by dllo on 16/3/4.
 */
public class SearchUserMImpl implements SearchUserMI {


    @Override
    public void verification(final String username, final OnSearchUserListener listener) {
        if (TextUtils.isEmpty(username)) {
            listener.onUserNull();
            return;
        }

        UserModel.getInstance().queryUsers(username, BaseModel.DEFAULT_LIMIT, new FindListener<User>() {
            @Override
            public void onSuccess( List<User> list) {
                listener.setList(list);
            }

            @Override
            public void onError(int i, String s) {
                listener.onSearchUserError(i, s);
            }
        });


    }
}
